<template>
	<view class="content">
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,index) in news" :key="index" @tap="openinfo" 
			:data-newsid="item.newsid" 
			:data-year="item.year" 
			:data-month="item.month">
				<view class="uni-media-list">					
					<view class="uni-media-list-body">
						<view class="uni-media-list-text-top">{{item.title}}</view>
						<view class="uni-media-list-text-bottom uni-ellipsis">
						  <text class="info-text">  {{item.source}} </text>
						
						<!-- 
						{{item.datetime}} -->
						</view>
						
						
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				news : []
			};
		},
		onLoad:function(){
			uni.showLoading({
				title:"加载中...."
			})
			this.$http.get("/taskscheduler/taCztTaskscheduler/listCx",{
							  params: ''
							  }).then(res=> {						
									if (res.data.code == 200) {	
										this.news =res.data.result.records;
										this.news = this.news.map((item) => {
											  return {
											   newsid: item.taskid,
											   datetime: item.year+'年'+item.month+'月',
											   title: item.tasktitle,
											   image_url: null,
											   source: item.tasktype_dictText,
											   comment_count: 0,
											   post_id: '',
											   month:item.month,
											   year:item.year
											  };
											});			
										uni.hideLoading();
										
										}else{
										if (this.news.length == 0) {
										 // this.isNoData = true;
										}
									}
							}).catch(e=>{
								if (this.news.length == 0) {
								   // this.isNoData = true;
								 }
								console.log("请求错误",e)
							});
		},
		methods: {
			openinfo(e) {
				var newsid = e.currentTarget.dataset.newsid;
				var year = e.currentTarget.dataset.year;
				var month = e.currentTarget.dataset.month;
				uni.navigateTo({
				    url: '/pages/zdrw/info?newsid=' + newsid+'&year='+year+
					'&month='+month
				});
			}
		},
	}
</script>

<style>

	/*每个页面公共css */
	@import "uni.css";
	page,
	view {
		display: flex;/* uni-app默认使用flex布局。因为flex布局有利于跨更多平台，尤其是采用原生渲染的平台。如不了解flex布局，请参考http://www.w3.org/TR/css3-flexbox/。若不需要flex布局可删除本行*/
	}
	
.uni-media-list-body{height: auto;}
.uni-media-list-text-top{line-height:1.6em;}
</style>
